package com.grm.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.grm.annotation.Log;
import com.grm.common.Result;
import com.grm.entity.User;
import com.grm.enums.CodeMessageEnum;

@RestController
@RequestMapping("/user")
public class UserController {
	private static Logger logger = LoggerFactory.getLogger(UserController.class);
	
	/**
	 * desc: 通过添加用户接口，测试aop实现日志管理
	 *
	 * @param user
	 * @return
	 */
	@Log("添加用户")
	@PostMapping("/insert")
	public Result insert(@RequestBody User user) {
		logger.info("[UserController] insert user success,user = {}",JSON.toJSONString(user));
		return Result.success(CodeMessageEnum.SUCCESS.getMessage());
	}
}
